<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        function fenye(cpage){
            $("[name='cpage']").val(cpage);
            $("form").submit();
        }

        function toadd(){
            location="toadd.do"
        }
        function checkFun(){
            $("[name='checkOne']").prop("checked",$("[name='checkAll']").prop("checked"));
        }
        function dels(){
            var ids=$("[name='checkOne']").map(function (){
               return $(this).val()
            }).get().join();
            $.post("dels.do",{"ids":ids},function (object){
                if(object>0){
                    location="list.do";
                }
            },"json")
        }
        function del(sid){
            $.post("dels.do",{"ids":sid},function (object){
                if(object>0){
                    location="list.do";
                }
            },"json")
        }
        function toupd(sid){
            location="toupd.do?sid="+sid;
        }
    </script>
</head>
<body>
<form action="list.do" method="post">
    <input type="hidden"  name="cpage">
    姓名：<input type="text" name="mohu1" value="${map.mohu1}"><br>
    生日:<input type="text" name="startTime"value="${map.startTime}" readonly onclick="WdatePicker()">--<input type="text" name="endTime" value="${map.endTime}" readonly onclick="WdatePicker()">
    <input type="submit">
</form>
<table>
    <tr>
        <td>
            <input type="checkbox" name="checkAll" onclick="checkFun()">
        </td>
        <td>编号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>爱好</td>
        <td>生日</td>
        <td>住址</td>
        <td>头像</td>
        <td>课程</td>
        <td>
            <input type="button" onclick="toadd()" value="添加">
            <input type="button" onclick="dels()" value="批量删除">
        </td>
    </tr>
    <c:forEach items="${pi.list}" var="s">
        <tr>
            <td>
                <input type="checkbox" name="checkOne" value="${s.sid}">
            </td>
            <td>${s.sid}</td>
            <td>${s.sname}</td>
            <td>${s.sex}</td>
            <td>${s.hobby}</td>
            <td>${s.birthday}</td>
            <td>${s.shengName}-${s.shiName}-${s.xianName}</td>
            <td>
                <img alt="无法展示" src="${s.pic}" width="120px">
            </td>
            <td>${s.cnames}</td>
            <td>
                <input type="button" value="删除" onclick="del(${s.sid})">
                <input type="button" value="修改" onclick="toupd(${s.sid})">
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="11">
            <input type="button" value="首页" onclick="fenye(1)"></inpuit>
            <input type="button" value="上一页" onclick="fenye(${pi.isFirstPage?1:pi.prePage})"></inpuit>
            <input type="button" value="下一页" onclick="fenye(${pi.isLastPage?pi.pages:pi.nextPage})"></inpuit>
            <input type="button" value="尾页" onclick="fenye(${pi.pages})"></inpuit>
        </td>
    </tr>
</table>
</body>
</html>